package cn.edu.lzu.unitweb.controller;

import cn.edu.lzu.entity.ExamineItemUnits;
import cn.edu.lzu.entity.Examiner;
import cn.edu.lzu.service.ExamineItemUnitsService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.support.DefaultSubjectContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @PackageName: cn.edu.lzu.unitweb.controller
 * @ClassName: ExamineItemUnitsController
 * @Description: TODO 体检项目计量单位控制器
 * @Author: 张琦[QQ:3098086691]
 * @Date: 2020/1/12 16:19
 * @Version: 1.0
 */
@Controller
public class ExamineItemUnitsController {
    @Resource
    private ExamineItemUnitsService examineItemUnitsService;

    @ResponseBody
    @RequestMapping("/getItemUnitsList")
    public List<ExamineItemUnits> getItemUnitsList(){
        Session session= SecurityUtils.getSubject().getSession();
        Examiner examiner=(Examiner)((PrincipalCollection)session.getAttribute(DefaultSubjectContext.PRINCIPALS_SESSION_KEY)).getPrimaryPrincipal();
        long unitId=examiner.getUnitId();
        List<ExamineItemUnits> examineItemUnitsList=examineItemUnitsService.getExamineItemUnitsList(unitId);
        return examineItemUnitsList;
    }
}
